C# 自訂義搜尋控件


使用這個方法就可以更方便的搜尋需要的Controls

// 遞迴尋找控制項的方法
private Control FindControlByName(Control parentControl, string name)
{
    if (parentControl.Name == name)
    {
        return parentControl;
    }

    foreach (Control childControl in parentControl.Controls)
    {
        Control targetControl = FindControlByName(childControl, name);
        if (targetControl != null)
        {
            return targetControl;
        }
    }

    return null;
}
#C# #Winform







你可能感興趣的文章

同步 & 非同步(5) - Promise.all 與 並行

同步 & 非同步(5) - Promise.all 與 並行

用PHP實作一個懷舊風留言板

用PHP實作一個懷舊風留言板

七天打造自己的 Google Map 應用入門 - Day04

七天打造自己的 Google Map 應用入門 - Day04






留言討論